package Behavioral.Strategy.demo2;

import java.util.Comparator;

public class Sorter {

	public static <T> void sort(T[] arr, Comparator<T> comparator) {
		for (int i = 0; i < arr.length; i++) {
			int minPos = i;
			for (int j = i + 1; j < arr.length; j++) {
				minPos = comparator.compare(arr[j], arr[minPos]) < 0 ? j : minPos;
			}
			// swap
			T temp = arr[i];
			arr[i] = arr[minPos];
			arr[minPos] = temp;
		}
	}


}
